package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo05 {
    public static void main(String[] args) {
        try(Connection connection = DBUtil.getConnection();){
          Statement statement = connection.createStatement();

          String sql = "SELECT username, password,age FROM userinfo";

            ResultSet r = statement.executeQuery(sql);

            while(r.next()){
                String username = r.getString("username");
                String password = r.getString("password");
                int age = r.getInt("age");
                System.out.println(username + "-" + password + "-" + age);
            }

        } catch(SQLException e){
            throw new RuntimeException(e);
        }
    }
}
